/*!
 * Interface file for joints between rigid bodies.
 */
#ifndef PHXJOINTS_H_INCLUDE_GUARD
#define PHXJOINTS_H_INCLUDE_GUARD

#include "PhxContactGenerator.h"

namespace phx 
{
    /*!
     * Joints link together two rigid bodies and make sure they do not
     * separate.      
	 */
    class Joint : public ContactGenerator
    {
    public:
        /*!
         * Holds the two rigid bodies that are connected by this joint.
         */
        RigidBody* mBodies[2];

        /*!
         * Holds the relative location of the connection for each
         * body, given in local coordinates.
         */
        Vector3 mPositions[2];

        /*!
         * Holds the maximum displacement at the joint before the
         * joint is considered to be violated. This is normally a
         * small, epsilon value.
         */
        real mError;

        /**
         * Configures the joint in one go.
         */
        void Set(
            RigidBody* bodyOne, const Vector3& positionOne,
            RigidBody* bodyTwo, const Vector3& positionTwo,
            real error
            );

        /**
         * Generates the contacts required to restore the joint if it
         * has been violated.
         */
        unsigned AddContact(Contact* contact, unsigned limit) const;
    };
} 

#endif // PHXJOINTS_H_INCLUDE_GUARD